package com.example.springsecurity.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springsecurity.entity.SystemOperationLog;

/**
 * 系统操作日志(SystemOperationLog)表数据库访问层
 *
 * @author makejava
 * @since 2025-01-16 15:20:21
 */
@Mapper
public interface SystemOperationLogMapper extends BaseMapper<SystemOperationLog> {

    /**
     * 清空系统操作日志表
     * @return
     */
    @Delete("TRUNCATE TABLE system_operation_log")
    int clean();

    /**
     * 删除7前天的系统操作日志数据
     * @return
     */
    @Delete("DELETE FROM system_operation_log WHERE DATE_FORMAT(create_time, '%Y-%m-%d') <= DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)")
    int delete7DaysAgoData();
}
